<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Dashboard">
    <meta name="keyword" content="Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">

    <title>DASHGUM - Bootstrap Admin Template</title>

    {% load static %}
    <link rel="stylesheet" href="{% static 'assets/css/style-qr.css' %}">
    <link rel="stylesheet" href="{% static 'assets/css/notice.min.css' %}">
    <link rel="stylesheet"
          href="{% static 'assets/css/default.min.css' %}">

    <!-- Bootstrap core CSS -->
    <link href="{% static 'assets/css/bootstrap.css' %}" rel="stylesheet">
    <!--external css-->
    <link href="{% static 'assets/font-awesome/css/font-awesome.css' %}" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="{% static 'assets/js/bootstrap-datepicker/css/datepicker.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'assets/js/bootstrap-daterangepicker/daterangepicker.css' %}" />
        
    <!-- Custom styles for this template -->
    <link href="{% static 'assets/css/style.css' %}" rel="stylesheet">
    <link href="{% static 'assets/css/style-responsive.css' %}" rel="stylesheet">

    <link href="{% static 'assets/css/purchase.css' %}" rel="stylesheet">
    <link href="{% static 'assets/css/the-datepicker.css' %}" rel="stylesheet">



  </head>

  <body>

  <section id="container" >
      <!-- **********************************************************************************************************************************************************
      TOP BAR CONTENT & NOTIFICATIONS
      *********************************************************************************************************************************************************** -->
      <!--header start-->
      <header class="header black-bg">
              <div class="sidebar-toggle-box">
                  <div class="fa fa-bars tooltips" data-placement="right" data-original-title="Toggle Navigation"></div>
              </div>
            <!--logo start-->
            <a href="index.html" class="logo"><b>DASHGUM FREE</b></a>
            <!--logo end-->
            <div class="nav notify-row" id="top_menu">
                <!--  notification start -->
                <ul class="nav top-menu">
                    <!-- settings start -->
                    <li class="dropdown">
                        <a data-toggle="dropdown" class="dropdown-toggle" href="index.html#">
                            <i class="fa fa-tasks"></i>
                            <span class="badge bg-theme">4</span>
                        </a>
                        <ul class="dropdown-menu extended tasks-bar">
                            <div class="notify-arrow notify-arrow-green"></div>
                            <li>
                                <p class="green">You have 4 pending tasks</p>
                            </li>
                            <li>
                                <a href="index.html#">
                                    <div class="task-info">
                                        <div class="desc">DashGum Admin Panel</div>
                                        <div class="percent">40%</div>
                                    </div>
                                    <div class="progress progress-striped">
                                        <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
                                            <span class="sr-only">40% Complete (success)</span>
                                        </div>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="index.html#">
                                    <div class="task-info">
                                        <div class="desc">Database Update</div>
                                        <div class="percent">60%</div>
                                    </div>
                                    <div class="progress progress-striped">
                                        <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%">
                                            <span class="sr-only">60% Complete (warning)</span>
                                        </div>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="index.html#">
                                    <div class="task-info">
                                        <div class="desc">Product Development</div>
                                        <div class="percent">80%</div>
                                    </div>
                                    <div class="progress progress-striped">
                                        <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%">
                                            <span class="sr-only">80% Complete</span>
                                        </div>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="index.html#">
                                    <div class="task-info">
                                        <div class="desc">Payments Sent</div>
                                        <div class="percent">70%</div>
                                    </div>
                                    <div class="progress progress-striped">
                                        <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width: 70%">
                                            <span class="sr-only">70% Complete (Important)</span>
                                        </div>
                                    </div>
                                </a>
                            </li>
                            <li class="external">
                                <a href="#">See All Tasks</a>
                            </li>
                        </ul>
                    </li>
                    <!-- settings end -->
                    <!-- inbox dropdown start-->
                    <li id="header_inbox_bar" class="dropdown">
                        <a data-toggle="dropdown" class="dropdown-toggle" href="index.html#">
                            <i class="fa fa-envelope-o"></i>
                            <span class="badge bg-theme">5</span>
                        </a>
                        <ul class="dropdown-menu extended inbox">
                            <div class="notify-arrow notify-arrow-green"></div>
                            <li>
                                <p class="green">You have 5 new messages</p>
                            </li>
                            <li>
                                <a href="index.html#">
                                    <span class="photo"><img alt="avatar" src="assets/img/ui-zac.jpg"></span>
                                    <span class="subject">
                                    <span class="from">Zac Snider</span>
                                    <span class="time">Just now</span>
                                    </span>
                                    <span class="message">
                                        Hi mate, how is everything?
                                    </span>
                                </a>
                            </li>
                            <li>
                                <a href="index.html#">
                                    <span class="photo"><img alt="avatar" src="assets/img/ui-divya.jpg"></span>
                                    <span class="subject">
                                    <span class="from">Divya Manian</span>
                                    <span class="time">40 mins.</span>
                                    </span>
                                    <span class="message">
                                     Hi, I need your help with this.
                                    </span>
                                </a>
                            </li>
                            <li>
                                <a href="index.html#">
                                    <span class="photo"><img alt="avatar" src="assets/img/ui-danro.jpg"></span>
                                    <span class="subject">
                                    <span class="from">Dan Rogers</span>
                                    <span class="time">2 hrs.</span>
                                    </span>
                                    <span class="message">
                                        Love your new Dashboard.
                                    </span>
                                </a>
                            </li>
                            <li>
                                <a href="index.html#">
                                    <span class="photo"><img alt="avatar" src="assets/img/ui-sherman.jpg"></span>
                                    <span class="subject">
                                    <span class="from">Dj Sherman</span>
                                    <span class="time">4 hrs.</span>
                                    </span>
                                    <span class="message">
                                        Please, answer asap.
                                    </span>
                                </a>
                            </li>
                            <li>
                                <a href="index.html#">See all messages</a>
                            </li>
                        </ul>
                    </li>
                    <!-- inbox dropdown end -->
                </ul>
                <!--  notification end -->
            </div>
            <div class="top-menu">
            	<ul class="nav pull-right top-menu">
                    <li><a class="logout" href="login.html">Logout</a></li>
            	</ul>
            </div>
        </header>
      <!--header end-->
      
      <!-- **********************************************************************************************************************************************************
      MAIN SIDEBAR MENU
      *********************************************************************************************************************************************************** -->
      <!--sidebar start-->
      <aside>
          <div id="sidebar"  class="nav-collapse ">
              <!-- sidebar menu start-->
              <ul class="sidebar-menu" id="nav-accordion">
              
              	  <p class="centered"><a href="profile.html"><img src="assets/img/ui-sam.jpg" class="img-circle" width="60"></a></p>
              	  <h5 class="centered">Marcel Newman</h5>
              	  	
                  <li class="mt">
                      <a href="index.html">
                          <i class="fa fa-dashboard"></i>
                          <span>Dashboard</span>
                      </a>
                  </li>

                  <li class="sub-menu">
                      <a href="javascript:;" >
                          <i class="fa fa-desktop"></i>
                          <span>UI Elements</span>
                      </a>
                      <ul class="sub">
                          <li><a  href="general.html">General</a></li>
                          <li><a  href="buttons.html">Buttons</a></li>
                          <li><a  href="panels.html">Panels</a></li>
                      </ul>
                  </li>

                  <li class="sub-menu">
                      <a href="javascript:;" >
                          <i class="fa fa-cogs"></i>
                          <span>Components</span>
                      </a>
                      <ul class="sub">
                          <li><a  href="calendar.html">Calendar</a></li>
                          <li><a  href="gallery.html">Gallery</a></li>
                          <li><a  href="todo_list.html">Todo List</a></li>
                      </ul>
                  </li>
                  <li class="sub-menu">
                      <a href="javascript:;" >
                          <i class="fa fa-book"></i>
                          <span>Extra Pages</span>
                      </a>
                      <ul class="sub">
                          <li><a  href="blank.html">Blank Page</a></li>
                          <li><a  href="login.html">Login</a></li>
                          <li><a  href="lock_screen.html">Lock Screen</a></li>
                      </ul>
                  </li>
                  <li class="sub-menu">
                      <a class="active" href="javascript:;" >
                          <i class="fa fa-tasks"></i>
                          <span>Forms</span>
                      </a>
                      <ul class="sub">
                          <li class="active"><a  href="form_component.html">Form Components</a></li>
                      </ul>
                  </li>
                  <li class="sub-menu">
                      <a href="javascript:;" >
                          <i class="fa fa-th"></i>
                          <span>Data Tables</span>
                      </a>
                      <ul class="sub">
                          <li><a  href="basic_table.html">Basic Table</a></li>
                          <li><a  href="responsive_table.html">Responsive Table</a></li>
                      </ul>
                  </li>
                  <li class="sub-menu">
                      <a href="javascript:;" >
                          <i class=" fa fa-bar-chart-o"></i>
                          <span>Charts</span>
                      </a>
                      <ul class="sub">
                          <li><a  href="morris.html">Morris</a></li>
                          <li><a  href="chartjs.html">Chartjs</a></li>
                      </ul>
                  </li>

              </ul>
              <!-- sidebar menu end-->
          </div>
      </aside>
      <!--sidebar end-->
      
      <!-- **********************************************************************************************************************************************************
      MAIN CONTENT
      *********************************************************************************************************************************************************** -->
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper">
          	<h3><i class="fa fa-angle-right"></i> 修改采购申请</h3>
          	
          	<!-- BASIC FORM ELELEMNTS -->
          	<div class="row mt">
                <div class="col-lg-12">
                <div class="form-panel">
                      <h4 class="mb"><i class="fa fa-angle-right"></i> 基本信息</h4>
                    <form class="form-horizontal style-form" method="get">
                      {% for c in purchaseRequisition %}
                      <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">采购申请编码</label>
                          <div class="col-lg-10">
                              <p class="form-control-static" id="rid">{{c.id}}</p>
                          </div>
                      </div>
                      
                      <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">创建者编码</label>
                          <div class="col-lg-10">
                              <p class="form-control-static">{{c.euser_id}}</p>
                          </div>
                      </div>
                      <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">创建时间</label>
                          <div class="col-lg-10">
                              <p class="form-control-static">{{c.time}}</p>
                          </div>
                      </div>
                      <div class="form-group">
                          <label class="col-sm-2 col-sm-2 control-label">备注</label>
                          <div class="col-sm-10">
                              <textarea rows="3" type="text" class="form-control" value="{{c.text}}"></textarea>
                          </div>
                      </div>
                      {%endfor%}
                      <div class="form-group">
                      <div class="col-md-12 mt">
                          <div class="content-panel">
                              <table class="table table-hover">
                               <div id="table-pr-head"> <h4><i class="fa fa-angle-right"></i> 商品信息</h4>
                              
                              </div>  
                                  <thead>
                                  <tr>
                                      <th>#&nbsp 条目编码</th>
                                      <th>商品编码</th>
                                      <th>商品名称</th>
                                      <th>估价</th>
                                      <th>货币单位</th>
                                      <th>数量</th>
                                      <th>送货时间</th>
                                      <th>工厂</th>
                                      <th>存储位置</th>
                                      <th>状态</th>
                                      <th></th>
                                  </tr>
                                  </thead>
                                  <tbody id="gooddiv"> 
                                      {% for c in reuqe %}
                                      <tr>
                                          <td class="td-text"> <input type="text" class="form-control td-text-modify" value="{{c.itemId}}" ></td>
                                          <td class="td-text"> <input type="text" class="form-control td-text-modify" value="{{c.meterial__id}}" ></td>
                                          <td class="td-text"> <input type="text" class="form-control td-text-modify" value="{{c.meterial__material__mname}}"></td>
                                          <td class="td-text"> <input type="text" class="form-control td-text-modify" value="{{c.estimatedPrice}}"></td>
                                          <td class="td-text"> <input type="text" class="form-control td-text-modify" value="{{c.currency}}"></td>
                                          <td class="td-text"> <input type="text" class="form-control td-text-modify" value="{{c.quantity}}"></td>
                                          <td class="td-text"> <input type="text" class="form-control td-text-modify"  value="{{c.deliveryDate}}"onclick="date(this)"></td> 
                                          <td class="td-text"> <input type="text" class="form-control td-text-modify" value="{{c.meterial__material__mname}}"></td>
                                          <td class="td-text"> <input type="text" class="form-control td-text-modify" value="{{c.meterial__sloc}}"></td>
                                          <td class="td-text" id="state">{{c.status}}</td>
                                          <td>
                                              <button  class="btn btn-link" onclick="save(this)">保存</button> <!--不同状态保存成功失败的判断-->
                                          </td>
                                      </tr>
                                      {%endfor%}
                              </tbody>
                              </table>
          
          </div><! --/content-panel -->
         
          </div><!-- /col-md-12 -->
      </div>
      <div id="btn-pr-create">
          <button type="button" class="btn btn-primary btn-lg btn-block">保存采购申请</button>
      </div>
                    </form>
                </div>
                </div><!-- col-lg-12-->      	
            </div><!-- /row -->
                        
                          

       

		</section><! --/wrapper -->
       
      </section><!-- /MAIN CONTENT -->
  
      <!--main content end-->
      <!--footer start-->
      <footer class="site-footer">
          <div class="text-center">
              2022 - ERP
              <a href="pr-create.html" class="go-top">
                  <i class="fa fa-angle-up"></i>
              </a>
          </div>
      </footer>
      <!--footer end-->
  </section>

 <!-- js placed at the end of the document so the pages load faster -->
    <script src="{% static 'assets/js/jquery.js' %}"></script>
    <script src="{% static 'assets/js/bootstrap.min.js' %}"></script>
    <script class="include" type="text/javascript" src="{% static 'assets/js/jquery.dcjqaccordion.2.7.js' %}"></script>
    <script src="{% static 'assets/js/jquery.scrollTo.min.js' %}"></script>
    <script src="{% static 'assets/js/jquery.nicescroll.js' %}" type="text/javascript"></script>
    <!--common script for all pages-->
    <script src="{% static 'assets/js/common-scripts.js' %}"></script>

    <!--script for this page-->
    <script src="{% static 'assets/js/jquery-ui-1.9.2.custom.min.js' %}"></script>

	<!--custom switch-->
	<script src="{% static 'assets/js/bootstrap-switch.js' %}"></script>
	
	<!--custom tagsinput-->
	<script src="{% static 'assets/js/jquery.tagsinput.js' %}"></script>
	
	<!--custom checkbox & radio-->

	<script src="{% static 'assets/js/form-component.js' %}"></script> 

    <script src="{% static 'assets/js/highlight.min.js' %}"></script>
    <script>
        hljs.highlightAll();
    </script>

    <script src="{% static 'assets/js/notice.min.js' %}"></script>
    <script>
        const notice = new Notice();
    </script>

    <script src="{% static 'assets/js/main-qr.js' %}"></script>
   
        <script src="{% static 'assets/js/the-datepicker.js' %}"></script>
        
        <script>
            function date(time){
            var datepicker = new TheDatepicker.Datepicker(time);
            datepicker.render();
            }
    </script>

<script>
   /* confirmo.init({
        yesBg: 'red',
        noBg: 'green'
    });
     function hello() {

        alert('修改成功');

    }
    */
    function save(nowTr){ //保存
        //保存失败
        var rid=document.getElementById("rid").innerHTML
        var itemId = $(nowTr).parent().parent().children().eq(0).children().val();
        var mid = $(nowTr).parent().parent().children().eq(1).children().val();
        var mname = $(nowTr).parent().parent().children().eq(2).children().val();
        var estimatedPrice = $(nowTr).parent().parent().children().eq(3).children().val();
        var currency = $(nowTr).parent().parent().children().eq(4).children().val();
        var quantity = $(nowTr).parent().parent().children().eq(5).children().val();
        var deliveryDate = $(nowTr).parent().parent().children().eq(6).children().val();
        var plant = $(nowTr).parent().parent().children().eq(7).children().val();
        var sloc = $(nowTr).parent().parent().children().eq(8).children().val();
        var $td=$(nowTr).parent().parent();
        var state=$td.find("#state").text();
        console.log(rid,itemId,mid,mname,estimatedPrice,currency,quantity,deliveryDate,plant,sloc)
        $.ajax({
            type: 'post',
            url: '',
            data:{
              "rid": rid
              "itemId": itemId,
              "meterial__id": mid,
              "mname": mname,
              "estimatedPrice": estimatedPrice,
              "currency": currency,
              "quantity": quantity,
              "deliveryDate": deliveryDate,
              "meterial__material__mname": plant,
              "meterial__sloc": sloc
          },
            success: function (data) {
                alert(1);
                showMessage({text: '保存商品信息成功！',type: 'success'})
           
         }   
      })
   

    }
</script>

</body>
</html>
